/*****************************************************************************
 * Open MCT, Copyright (c) 2014-2018, United States Government
 * as represented by the Administrator of the National Aeronautics and Space
 * Administration. All rights reserved.
 *
 * Open MCT is licensed under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * http://www.apache.org/licenses/LICENSE-2.0.
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations
 * under the License.
 *
 * Open MCT includes source code licensed under additional open source
 * licenses. See the Open Source Licenses file (LICENSES.md) included with
 * this source code distribution or the Licensing information page available
 * at runtime from the About dialog for additional information.
 *****************************************************************************/
.abs.holder-plot {
    right: $interiorMargin; // Fend off the scrollbar when less than min-height;
    .t-object-alert.t-alert-unsynced {
        display: none;
    }
}

/********************************************* STACKED PLOT LAYOUT */
.t-plot-stacked {
    .l-view-section {
        //  Make this a flex container
        display: flex;
        flex-flow: column nowrap;
        .gl-plot.child-frame {
            mct-plot {
                display: flex;
                flex: 1 1 auto;
                height: 100%;
                position: relative;
            }
            flex: 1 1 auto;
            &:not(:first-child) {
                margin-top: $interiorMargin;
            }
        }
    }

    .s-status-timeconductor-unsynced .holder-plot {
        .t-object-alert.t-alert-unsynced {
            display: block;
        }
    }
}

.gl-plot {
    color: $colorPlotFg;
    display: flex;
    font-size: 0.7rem;
    position: relative;
    width: 100%;
    height: 100%;
    min-height: $plotMinH;

    /********************************************* AXIS AND DISPLAY AREA */
    .plot-wrapper-axis-and-display-area {
        margin-top: $interiorMargin; // Keep the top tick label from getting clipped
        position: relative;
        flex: 1 1 auto;
        .t-object-alert {
            position: absolute;
            display: block;
            font-size: 1.5em;
            top: $interiorMarginSm;
            left: $interiorMarginSm;
        }
    }

    .gl-plot-wrapper-display-area-and-x-axis {
        // Holds the plot area and the X-axis only
        position: absolute;
        top: nth($plotDisplayArea, 1);
        right: nth($plotDisplayArea, 2);
        bottom: 0;
        left: nth($plotDisplayArea, 4);

        .gl-plot-display-area {
            position: absolute;
            top: 0;
            right: 0;
            bottom: nth($plotDisplayArea, 3);
            left: 0;
        }

        .gl-plot-axis-area.gl-plot-x {
            top: auto;
            right: 0;
            bottom: 0;
            left: 0;
            height: $plotXBarH;
            width: auto;
            overflow: hidden;
        }
    }

    .gl-plot-axis-area {
        position: absolute;
        &.gl-plot-y {
            top: nth($plotDisplayArea, 1);
            right: auto;
            bottom: nth($plotDisplayArea, 3);
            left: 0;
            width: $plotYBarW;
        }
    }

    .gl-plot-coords {
        box-sizing: border-box;
        border-radius: $controlCr;
        background: black;
        color: lighten($colorBodyFg, 30%);
        padding: 2px 5px;
        position: absolute;
        top: nth($plotDisplayArea,1) + $interiorMarginLg;
        right: auto;
        bottom: auto;
        left: nth($plotDisplayArea,4) + $interiorMarginLg;
        z-index: 10;
        &:empty {
            display: none;
        }
    }

    .gl-plot-label,
    .l-plot-label {
        color: $colorPlotLabelFg;
        position: absolute;
        text-align: center;

        &.gl-plot-x-label,
        &.l-plot-x-label {
            top: auto;
            right: 0;
            bottom: 0;
            left: 0;
            height: auto;
        }

        &.gl-plot-y-label,
        &.l-plot-y-label {
            $x: -50%;
            $r: -90deg;
            transform-origin: 50% 0;
            transform: translateX($x) rotate($r);
            display: inline-block;
            margin-left: $interiorMargin; // Kick off the left edge
            left: 0;
            top: 50%;
            white-space: nowrap;
        }
    }

    .gl-plot-x-options,
    .gl-plot-y-options {
        $h: 24px;
        position: absolute;
        height: $h;
        min-height: $h;
        z-index: 2;
    }

    .gl-plot-x-options {
        transform: translateX(-50%);
        bottom: 0;
        left: 50%;
    }

    .gl-plot-y-options {
        transform: translateY(-50%);
        min-width: 150px; // Need this due to enclosure of .select
        top: 50%;
        left: $plotYLabelW + $interiorMargin * 2;
    }

    .t-plot-display-controls {
        position: absolute;
        top: $interiorMargin;
        right: $interiorMargin;
    }

    .gl-plot-hash {
        position: absolute;
        opacity: $opacityPlotHash;
        &.hash-v {
            border-right: 1px $colorPlotHash $stylePlotHash;
            height: 100%;
        }
        &.hash-h {
            border-bottom: 1px $colorPlotHash $stylePlotHash;
            width: 100%;
        }
    }

    /****************************** Limits and Out-of-Bounds data */

    .l-limit-bar,
    .l-oob-data {
        position: absolute;
        left: 0;
        right: 0;
        width: auto;
    }

    .l-limit-bar {
        // Limits in plot display area
        @mixin limitBg($c) {
            background: rgba($c, 0.2);
        }

        height: auto;
        z-index: 0;
        &.s-limit-yellow {
            @include limitBg($colorLimitYellowBg);
        }
        &.s-limit-red {
            @include limitBg($colorLimitRedBg);
        }
    }

    .l-oob-data {
        $c: #7748d6;
        $a: 0.5;
        $h: 10px;
        @include absPosDefault();
        pointer-events: none;
        height: $h;
        z-index: 1;
        &.l-oob-data-up {
            top: 0;
            bottom: auto;
            @include linearGlow(0deg, $c, $a);
        }
        &.l-oob-data-dwn {
            bottom: 0;
            top: auto;
            @include linearGlow(180deg, $c, $a);
        }
    }
}

.gl-plot-display-area,
.plot-display-area {
    @if $colorPlotBg != none {
        background-color: $colorPlotBg;
    }
    cursor: crosshair;
    border: 1px solid $colorPlotAreaBorder;
}

.tick {
    position: absolute;
    border: 0 $colorPlotHash solid;
    &.tick-x {
        border-right-width: 1px;
        height: 100%; // Assumption is that the tick will be in a holder that will set it's height;
    }
}

.gl-plot-tick,
.tick-label {
    font-size: 0.7rem;
    position: absolute;
    &.gl-plot-x-tick-label,
    &.tick-label-x {
        right: auto;
        bottom: auto;
        left: auto;
        height: auto;
        width: 20%;
        margin-left: -10%;
        text-align: center;
    }
    &.gl-plot-y-tick-label,
    &.tick-label-y {
        top: auto;
        height: 1em;
        width: auto;
        margin-bottom: -0.5em;
        text-align: right;
    }
}

.gl-plot-tick {
    &.gl-plot-x-tick-label {
        top: $interiorMargin;
    }
    &.gl-plot-y-tick-label {
        right: $interiorMargin;
        left: $interiorMargin;
    }
}

.tick-label {
    &.tick-label-x {
        top: 0;
    }
    &.tick-label-y {
        right: 0;
        left: 0;
    }
}

.export-plot {
    $bg: white;
    $fg: black;
    $gry: #999;

    background: $bg !important;
    z-index: -10;

    .l-view-section {
        $m: $interiorMargin;
        top: $m !important;
        right: $m;
        bottom: $m;
        left: $m;

        .s-status-timeconductor-unsynced .holder-plot {
            .t-object-alert.t-alert-unsynced {
                display: none;
            }
        }
    }

    .gl-plot-display-area {
        background: none !important;
        border-color: $gry !important;

        .gl-plot-local-controls,
        .h-local-controls {
            opacity: 0;
        }
    }

    .gl-plot {
        color: $fg;

        .gl-plot-hash {
            opacity: 0.1;
            border-color: $fg;
        }
    }

    table {
        thead {
            border-bottom: none;

            th {
                background: #eee;
                border-left-color: $bg;
                color: #666;
            }

            tr {
                border: none;
            }
        }
        tbody {
            tr {
                border-top: 1px solid #ccc;
            }

            td {
                color: $fg;
            }
        }
    }
}
